import { Component, OnInit, Input } from '@angular/core'
import { Widget } from '../../model'
import { JsonApiService } from '../../../../core/api/json-api.service'


@Component({
  selector: 'carry-distance',
  templateUrl: './carry-distance.html',
  styleUrls: ['./carry-distance.css']
})
// 运载里程
export class CarryDistance implements OnInit, Widget {
  @Input() componentData: any
  // @Input() auth = true

  data = {
    data: '',
    size: ''
  }
  loading = false


  constructor(private jsonApiService: JsonApiService) { }
  ngOnInit() {
    this.initData()
  }

  //当天总流量
  initData() {
    this.loading = true
    this.jsonApiService.http('control/station/carry/distance/carryDistance.html', null, false).subscribe(data => {
      this.loading = false
      if (data.success) {
        this.data = common.numberFormat(data.data);
      } else {
        this.jsonApiService.message(data.message);
      }
    })
  }
}
